package com.smashit.tacocloud.config;

import com.smashit.tacocloud.converter.IngredientConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jinshan_jiang
 * @version 1.0
 * @since 2024/4/9
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    private final IngredientConverter ingredientConverter;

    public WebConfig(IngredientConverter ingredientConverter) {
        this.ingredientConverter = ingredientConverter;
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(ingredientConverter);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("home");
        registry.addViewController("/login");
    }
}
